var app = getApp()

Page({
  data: {
    currentTab: 0,
    winHeight:"",
    item_list:[],
    att_list_item:[]
  },
  onLoad: function (options) {
    var that = this;
    //  高度自适应
    wx.getSystemInfo({
      success: function (res) {
        console.log(res)
        var clientHeight = res.windowHeight,
          clientWidth = res.windowWidth,
          rpxR = 750 / clientWidth;
        var calc = clientHeight * rpxR - 175* rpxR;
        that.setData({
          winHeight: calc
        });
      }
    });
//拿缓存数据
  },
  //滑动切换
  swiperTab: function (e) {
    var that = this;
    that.setData({
      currentTab: e.detail.current
    });
    console.log
  },
  //点击切换
  clickTab: function (e) {
    var that = this;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
    }
  },
  onShow(){
    //历史记录
    var list=wx.getStorageSync('history')
    this.setData({
      item_list:list
    })
    //关注记录
    var a_list=wx.getStorageSync('attent')
    this.setData({
      att_list_item:a_list
    })
  },
  // 关注取消
  a_del(e){
    var att_list=wx.getStorageSync('attent')
    var s_name=[]
    att_list.forEach(function(ele,i){
      s_name.push(ele.title)
      if(ele.title==e.currentTarget.dataset.name){
        att_list.splice(i,1);
      }
    })
    wx.setStorageSync('attent',att_list)
    this.setData({
      att_list_item:att_list
    })
  }

})